<template>
	<view class="w-full pt-10">
		<view class="w-full flex bgfff py-20 pl-30">
			<view class="round-50-p w-30n h-30n overflow-hidden">
				<image class="box-full" mode="aspectFill" :src="userInfo.avatar" alt="" />
			</view>
			<view class="ml-20 flex-col flex-j-c">
				<view class="text-size-30">{{userInfo.nickname}}</view>
			</view>
			<view class="absolute r-6n t-20" @click="toSetting">
				<uni-icons type="gear" color="#000" size="34" style="font-size: 44rpx"></uni-icons>
			</view>
		</view>
		<view class="w-full bgfff py-20 pl-10 mt-20">
			<uni-list class="w-full mt-20">
				<uni-list-item :show-extra-icon="true" :extra-icon="{type:'tune',size:20}" title="我的投票" link
					@click="toMyVote"></uni-list-item>
				<uni-list-item :show-extra-icon="true" :extra-icon="{type:'gear',size:20}" title="设置" link
					@click="toSetting"></uni-list-item>
				<uni-list-item :show-extra-icon="true" :extra-icon="{type:'upload',size:20}" title="退出登录"
					link></uni-list-item>
			</uni-list>
		</view>
	</view>
</template>

<script setup>
	import {
		myInfo
	} from '@/network/api.js'
	const userInfo = ref()
	// 获取我的详情
	const getMyInfo = async () => {
		const res = await myInfo()
		if (res.status === 200) {
			userInfo.value = res.data
		} else {
			uni.showToast({
				title: res.msg,
				icon: 'none'
			})
		}

		console.log(res)
	}

	// 跳转我的投票
	const toMyVote = () => {
		uni.navigateTo({
			url: '/pages/mine/myVote'
		})
	}

	// 跳转我的设置
	const toSetting = () => {
		uni.navigateTo({
			url: '/pages/mine/setting'
		})
	}

	onShow(() => {
		getMyInfo()
	})
</script>

<style scoped lang="scss">

</style>